package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cskaoyan.mall.commons.result.ResponseUtil;

import javax.xml.ws.Response;
import java.util.Set;

/**
 * @author: 杨庆
 * @since: 2022.9.21 09:05
 * @description:
 */
@RestController
@RequestMapping("shopping")
public class ShoppingSelectController {
    @Autowired
    IProductService iProductService;

    /**
    * @description:  全部商品的展示
    [request]
    * @return: com.cskaoyan.mall.commons.result.ResponseData
    * @author: 杨庆
    * @time: 2022.9.21 10:31
     */
    @GetMapping("goods")
    public ResponseData goods(PageRequest request) {
        //返回result类型 AllProductResponse
        AllProductResponse allProduct = iProductService.getAllProduct(request);
        return new ResponseUtil<AllProductResponse>().setData(allProduct);
    }

    /**
    * @description: 商品推荐的模块
    []
    * @return: com.cskaoyan.mall.commons.result.ResponseData
    * @author: 杨庆
    * @time: 2022.9.21 10:36
     */
    @GetMapping("recommend")
    public ResponseData recommend() {
        Set<PanelDto> recommendGoods = iProductService.getRecommendGoods();
        return new ResponseUtil<>().setData(recommendGoods);
    }


}
